package com.bioroadlab.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;

import com.bioroadlab.web.RandomValidateCode;


public class ImageAction extends BaseAction {

	private static final long serialVersionUID = 1L;
	private String houtaiCode;
	private String unUsedData;

	@Override
	public String execute() throws Exception {
		return null;
	}

	@Action("image")
	public void getImage() {
		HttpServletResponse response = ServletActionContext.getResponse();
		HttpServletRequest request = ServletActionContext.getRequest();
		response.setContentType("image/jpeg");
		response.setHeader("Pragma", "No-cache");
		response.setHeader("Cache-Control", "no-cache");
		response.setDateHeader("Expire", 0);
		RandomValidateCode randomValidateCode = new RandomValidateCode();
		try {
			houtaiCode=randomValidateCode.getRandcode(request, response);
			putInSession("randCode", houtaiCode);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public String getHoutaiCode() {
		return houtaiCode;
	}

	public void setHoutaiCode(String houtaiCode) {
		this.houtaiCode = houtaiCode;
	}

	public String getUnUsedData() {
		return unUsedData;
	}

	public void setUnUsedData(String unUsedData) {
		this.unUsedData = unUsedData;
	}

}
